<template>
	<view class="index-list animated fadeInLeft fast" >
		<view class="index-list1 u-f-ac u-f-jsb">
			<view class="u-f-ac firstchild">
				<image class="img" :src="item.userpic" mode="widthFix" lazy-load></image>
				{{item.username}}
			</view>
			<view class="u-f-ac guanzhu" v-show="!item.isguanzhu" @tap="guanzhu">
				<view class="icon iconfont icon-zengjia">关注</view>
			</view>
		</view>
		<view class="index-list2" @tap="opendetail">{{item.title}}</view>
		<view class="index-list3 u-f-ajc" @tap="opendetail">
			
			<!-- 图片 -->
			<image class="img" :src="item.titlepic" mode="widthFix" lazy-load></image>
			<!-- 视频 -->
			<template v-if="item.type === 'video'">
				<view class="icon iconfont icon-bofang index-list-play"></view>
				<view class="index-list-playinfo">{{item.playNum}}次播放 {{item.long}}</view>
			</template>
		</view>
		<view class="index-list4 u-f-ac u-f-jsb">
			<view class="u-f-ac">
				<view class="u-f-ac ding" :class="{'active':item.infoNum.index === 1}"
				@tap="caozuo('ding')">
					<view class="icon iconfont icon-icon_xiaolian-mian ac"></view>
					{{item.infoNum.dingNum}}
				</view>
				<view class="u-f-ac" :class="{'active':item.infoNum.index === 2}"
				@tap="caozuo('cai')">
					<view class="icon iconfont icon-kulian"></view>
					{{item.infoNum.caiNum}}
				</view>
			</view>
			<view class="u-f-ac">
				<view class="u-f-ac"><view class="icon iconfont icon-pinglun1"></view>{{item.commentNum}}</view>
				<view class="u-f-ac"><view class="icon iconfont icon-zhuanfa"></view>{{item.shareNum}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props:{
			item:Object,
			index:Number
		},
		methods:{
			//关注
			guanzhu(){
				this.item.isguanzhu = true;
				uni.showToast({
					title:"关注成功",
					icon:"success"
				});
			},
			//顶踩
			caozuo(type){
				console.log(type);
				switch (type) {
					case "ding":
						if (this.item.infoNum.index ==1){return;}
						this.item.infoNum.dingNum++;
						if (this.item.infoNum.index==2){
							this.item.infoNum.caiNum--;
						}
						this.item.infoNum.index = 1;
					break;
					case "cai":
						this.item.infoNum.index = 2	;
					break;
				}
			},
			opendetail(){
				uni.navigateTo({
					url:"/pages/detail/detail?detailData="+JSON.stringify(this.item),
				})
			}
		}
	}
</script>

<style scoped>
	.index-list {
		padding: 20upx;
		border-bottom: 1upx solid #EEEEEE;
	}
	
	.index-list1 .firstchild{
		color: #999999;
	}
	.index-list1 .firstchild .img {
		width: 85upx;
		height: 85upx;
		border-radius: 100%;
		margin-right: 10upx;
	}
	.index-list1 .guanzhu{
		background: #F4F4F4;
		border-radius: 5upx;
		padding: 0 10upx;
	}
	
	.index-list2 {
		padding: 15upx;
		font-size: 32upx;
	}
	
	.index-list3 {
		padding-top: 15upx;
		position: relative;
	}
	.index-list3 .img {
		width: 100%;
		border-radius: 10upx;
	}
	
	.index-list-play {
		position: absolute;
		font-size: 140upx;
		color: #FFFFFF;
	}
	
	.index-list-playinfo{
		position: absolute;
		background-color: rgba(51,51,51,0.72);
		color: #FFFFFF;
		bottom: 8upx;
		right: 8upx;
		border-radius: 40upx;
		font-size: 22upx;
		padding: 0 12upx;
	}
	
	.index-list4 {
		padding: 15upx 0;
		color: #999999;
	}
	
	.index-list4 .icon-icon_xiaolian-mian, .ding{
		margin-right: 10upx;
	}
	
	.index-list4 .active {
		color: #C5F61C;
	}
</style>
